<?php
/**
 *    @version [ Masterton ]
 *    @package hwdVideoShare
 *    @copyright (C) 2007 - 2009 Highwood Design
 *    @license Creative Commons Attribution-Non-Commercial-No Derivative Works 3.0 Unported Licence
 *    @license http://creativecommons.org/licenses/by-nc-nd/3.0/
 */
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

global $mainframe, $option, $smartyvs;

if (!file_exists(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS)) {
	echo "<div style=\"border:1px solid #c30;color:#c30;margin: 0 0 5px 0;padding: 5px;font-weight: bold;text-align:left;text-align:center;\">The hwdVideoShare component is not installed, you can not use this module.</div>"; return;
}

$db =& JFactory::getDBO();
$my = & JFactory::getUser();
require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'initialise.php');
hwdvsInitialise::coreRequire();
hwdvsInitialise::language();
hwdvsInitialise::template();
hwdvsInitialise::mysqlQuery();
hwdvsInitialise::definitions();

$c = hwd_vs_Config::get_instance();
$video_id = JRequest::getInt( 'video_id', null );

if (@_HWD_VS_PLUGIN_COMPS !== 214) {
	echo "<div style=\"border:1px solid #c30;color:#c30;margin: 0 0 5px 0;padding: 5px;font-weight: bold;text-align:left;text-align:center;\">This module is not compatible with your version of hwdVideoShare.</div>"; return;
}

$c = hwd_vs_Config::get_instance();
$video_id = JRequest::getInt( 'video_id', null );


$query = "SELECT *"
		. "\n FROM #__hwdvidsvideos"
		. " WHERE approved = 'yes' AND published = '1' "
		
		. ' ORDER BY RAND()'
		;

$db->SetQuery( $query,0,5 );
$Randomizes = $db->loadObjectList();

$query = "SELECT *"
	. "\n FROM #__hwdvidsvideos"
	. " WHERE approved = 'yes' AND published = '1' "
	
	. ' ORDER BY  featured DESC, ID DESC'
;

$db->SetQuery( $query,0,5 );
$popular = $db->loadObjectList();

$query = "SELECT *"
	. "\n FROM #__hwdvidsvideos"
	. " WHERE approved = 'yes' AND published = '1' "
	
	. ' ORDER BY  date_uploaded DESC, ID DESC'
;

$db->SetQuery( $query,0,5 );
$latest = $db->loadObjectList();

$latest = hwd_vs_tools::generateVideoListFromSql($latest, "", 110);
$popular = hwd_vs_tools::generateVideoListFromSql($popular, "", 110);
$Randomizes = hwd_vs_tools::generateVideoListFromSql($Randomizes, "", 110);

$smartyvs->assign("latest", $latest);
$smartyvs->assign("popular", $popular);
$smartyvs->assign("randomize", $Randomizes);
$smartyvs->assign("root", JURI::root());
$smartyvs->assign("hwdvids_params", $hwdvids_params);

$smartyvs->display('mod_hwd_vs_popular.tpl');
return;
?>
